import type { RouteRecordRaw } from 'vue-router';
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '#/utils/constants';

const BasicLayout = () => import('#/layouts/basic.vue');
const AuthLayout = () => import('#/layouts/login.vue');
const Lesson = () => import('#/layouts/lesson.vue')
const Exam = () => import('#/layouts/exam.vue')
const Home = () => import('#/layouts/home.vue')
const CompetitionHome = () => import('#/layouts/competition-home.vue')

/** 全局404页面 */
const fallbackNotFoundRoute: RouteRecordRaw = {
  component: () => import('#/views/_core/fallback/not-found.vue'),
  meta: {
    hideInBreadcrumb: true,
    hideInMenu: true,
    hideInTab: true,
    title: '404',
  },
  name: 'FallbackNotFound',
  path: '/:path(.*)*',
};

/** 基本路由，这些路由是必须存在的 */
const coreRoutes: RouteRecordRaw[] = [
  /**
   * 根路由
   * 使用基础布局，作为所有页面的父级容器，子级就不必配置BasicLayout。
   * 此路由必须存在，且不应修改
   */
  {
    component: BasicLayout,
    meta: {
      hideInBreadcrumb: true,
      title: 'Root',
    },
    name: 'Root',
    path: '/',
    redirect: DEFAULT_HOME_PATH,
    children: [],
  },
  {
    component: AuthLayout,
    meta: {
      hideInTab: true,
      title: 'Authentication',
    },
    name: 'Authentication',
    path: '/auth',
    redirect: LOGIN_PATH,
    children: [
      {//登录
        name: 'Login',
        path: 'login',
        component: () => import('#/views/logins/login.vue'),
        meta: {
          title: '登录',
        },
      },
      {//注册
        name: 'Register',
        path: 'register',
        component: () => import('#/views/logins/register.vue'),
        meta: {
          title: '注册',
        },
      },
      {//重置密码
        name: 'ResetPassword',
        path: 'resetPassword',
        component: () => import('#/views/logins/register.vue'),
        meta: {
          title: '重置密码',
        },
      },
      //证书查询
      {
        name: "CertVerify",
        path: 'certVerify',
        component: () => import('#/views/logins/cert-verify.vue'),
        meta: {
          title: '证书查询'
        }
      }
    ],
  },
  //课程
  {
    component: Lesson,
    meta: {
      hideInTab: true,
      title: '首页',
    },
    name: 'Lesson',
    path: '/lesson',
    redirect: '/homePage/homePageIndex',
    children: [
      // {
      //   name: 'TenantHome',
      //   path: 'tenant',
      //   component: () => import('#/views/lesson/tenant.vue'),
      //   meta: {
      //     title: '认证中心',
      //   }
      // },
      {
        name: 'Home',
        path: 'home/:id?',
        component: () => import('#/views/lesson/home.vue'),
        meta: {
          title: '认证首页',
        }
      },
      {
        name: 'Intro',
        path: 'intro',
        component: () => import('#/views/lesson/intro.vue'),
        meta: {
          title: '课程介绍',
        }
      },
      {
        name: 'Learn',
        path: 'learn/:id?',
        props: (route) => ({ id: route.params.id }),
        component: () => import('#/views/lesson/learn.vue'),
        meta: {
          title: '课程学习',
        },
      },
      {
        name: 'CertResult',
        path: 'certResult',
        component: () => import('#/views/lesson/cert-result.vue'),
        meta: {
          title: '查询结果',
        },
      },
      {
        name: 'PersonalCenter',
        path: 'personalCenter',
        component: () => import('#/views/personal/personal-center.vue'),
        redirect: '/lesson/personalCenter/personalHome',
        meta: {
          title: '个人中心',
        },
        children: [
          {
            name: 'PersonalHome',
            path: 'personalHome',
            component: () => import('#/views/personal/personal-home.vue'),
            meta: {
              title: '个人首页',
              hideInBreadcrumb: true,
            },
          },
          {
            name: 'PersonalProfile',
            path: 'personalProfile',
            component: () => import('#/views/personal/personal-profile.vue'),
            meta: {
              title: '个人信息',
            },
          },
          {
            name: 'UserMessage',
            path: 'userMessage',
            component: () => import('#/views/personal/user-message.vue'),
            meta: {
              title: '我的消息',
            },
          },
          {
            name: 'PersonalCertification',
            path: 'certification',
            component: () => import('#/views/personal/certification.vue'),
            meta: {
              title: '我的认证',
            },
          },
          {
            name: 'PersonalCourses',
            path: 'courses',
            component: () => import('#/views/personal/courses.vue'),
            meta: {
              title: '我的课程',
            },
          },
          {
            name: 'PersonalExams',
            path: 'exams',
            component: () => import('#/views/personal/exams.vue'),
            meta: {
              title: '我的考试',
            },
          },
          {
            name: 'PersonalCertificates',
            path: 'certificates',
            component: () => import('#/views/personal/certificates.vue'),
            meta: {
              title: '我的证书',
            },
          }
        ]
      }
    ]
  },
  {
    component: Exam,
    meta: {
      hideInTab: true,
      title: 'accreditExam',
    },
    name: 'AccreditExam',
    path: '/accreditExam',
    redirect: '/accreditExam/explainCore/',
    children: [
      {
        name: "ExplainCore",
        path: 'explainCore/:id?',
        component: () => import('#/views/exam/explain-core.vue'),
        meta: {
          title: '考试说明'
        }
      },
      {
        name: "ExamStart",
        path: 'examStart/:id',
        component: () => import('#/views/exam/modules/exam-start.vue'),
        meta: {
          title: '开始考试'
        }
      }
    ]
  },
  // 首页
  {
    component: Home,
    meta: {
      hideInTab: true,
      title: '首页',
    },
    name: 'HomePage',
    path: '/homePage',
    redirect: '/homePage/homePageCourse',
    children: [
      {
        name: 'HomePageIndex',
        path: 'homePageIndex',
        component: () => import('#/views/home/index.vue'),
        meta: {
          title: '首页',
        },
      },
      {
        name: 'HomePageCourse',
        path: 'homePageCourse',
        component: () => import('#/views/home/course.vue'),
        meta: {
          title: '课程',
        },
      },
      {
        name: 'HomePageTenant',
        path: 'homePageTenant',
        component: () => import('#/views/lesson/tenant.vue'),
        meta: {
          title: '认证中心',
        }
      },
    ]
  },
  // 大赛首页
  {
    component: CompetitionHome,
    meta: {
      hideInTab: true,
      title: '大赛首页',
    },
    name: 'CompetitionHomePage',
    path: '/competitionHomePage',
    redirect: '/competitionHomePage/competitionHomePageIndex',
    children: [
      {
        name: 'CompetitionHomePageIndex',
        path: 'competitionHomePageIndex',
        component: () => import('#/views/competitionHome/index.vue'),
        meta: {
          title: '大赛首页',
        },
      },
      {
        name: 'CompetitionHomePageContests',
        path: 'contests',
        component: () => import('#/views/competitionHome/contests.vue'),
        meta: {
          title: '作品提交',
        },
      },
      {
        name: 'CompetitionLives',
        path: 'competitionLives',
        component: () => import('#/views/competitionHome/lives.vue'),
        meta: {
          title: '大赛动态',
        },
      },
      {
        name: 'CompetitionLivesDetail',
        path: 'competitionLivesDetail/:compId/:groupId/detail/:id',
        props: (route) => ({ id: route.params.id }),
        component: () => import('#/views/competitionHome/modules/lives/detail.vue'),
        meta: {
          title: '大赛动态详情',
        },
      },
      {
        name: 'CompetitionTraining',
        path: 'competitionTraining',
        component: () => import('#/views/competitionHome/training.vue'),
        meta: {
          title: '培训资料',
        },
      },
    ]
  },
];

export { coreRoutes, fallbackNotFoundRoute };
